package com.zwl.openandclose;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import java.util.List;
import java.util.Map;

/**
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * ┃　　　┃   神兽保佑
 * ┃　　　┃   代码无BUG！
 * ┃　　　┗━━━┓
 * ┃　　　　　　　┣┓
 * ┃　　　　　　　┏┛
 * ┗┓┓┏━┳┓┏┛
 * ┃┫┫　┃┫┫
 * ┗┻┛　┗┻┛
 * create by 2017/3/28 15:01
 * annotation:
 */
public class ExpandListAdapter extends BaseExpandableListAdapter {

    Context context;

    List<String> parent;
    List<String> child;
    Map<List<String>,List<String>> dataGroup;

    public ExpandListAdapter( Context context,List<String> parent,List<String> child,Map<List<String>,List<String>> dataGroup) {

        this.context = context;
        this.parent = parent;
        this.child = child;
        this.dataGroup = dataGroup;
    }

    @Override
    public int getGroupCount() {
        return parent.size();
    }

    @Override
    public int getChildrenCount(int i) {
        System.out.println(child.size());
        return child.size();
    }

    @Override
    public Object getGroup(int i) {
        return null;
    }

    @Override
    public Object getChild(int i, int i1) {
        return null;
    }

    @Override
    public long getGroupId(int i) {
        return 0;
    }

    @Override
    public long getChildId(int i, int i1) {
        return 0;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {

        if (view == null){
            view = View.inflate(context, android.R.layout.simple_list_item_1,null);
        }

        TextView t = (TextView) view.findViewById(android.R.id.text1);
        t.setText(parent.get(i));
        return view;
    }

    @Override
    public View getChildView(int i, int i1, boolean b, View view, ViewGroup viewGroup) {

        if (view == null){
            view = View.inflate(context, android.R.layout.simple_list_item_1,null);
        }
        TextView t = (TextView) view.findViewById(android.R.id.text1);
        t.setText(child.get(i));
        return view;
    }

    @Override
    public boolean isChildSelectable(int i, int i1) {
        return false;
    }

    /*public ExpandListAdapter(Context context, List<? extends Map<String, ?>> groupData,

                             int groupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>>
                                     childData, int childLayout, String[] childFrom, int[] childTo) {

        super(context, groupData, groupLayout, groupFrom, groupTo, childData, childLayout, childFrom, childTo);
    }*/


}
